package mint2tcp;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.Parent;

public class MainApp extends Application {
    @Override
    public void start(Stage primaryStage) {
        System.out.println("JavaFX 应用已启动");
        // 调试输出 FXML 路径
        java.net.URL fxmlUrl = getClass().getResource("/main.fxml");
        System.out.println("FXML URL: " + fxmlUrl);
        System.out.println("当前工作目录: " + System.getProperty("user.dir"));

        try {
            System.out.println("Loading FXML file...");
            FXMLLoader loader = new FXMLLoader(fxmlUrl);
            Parent root = loader.load();

            System.out.println("FXML file loaded successfully.");
            primaryStage.setTitle("Mint2.0 TCP Clone");
            primaryStage.setScene(new Scene(root, 800, 600));
            primaryStage.show();
            new javafx.scene.control.Alert(javafx.scene.control.Alert.AlertType.INFORMATION, "启动成功").showAndWait();
        } catch (Exception e) {
            e.printStackTrace();
            new javafx.scene.control.Alert(javafx.scene.control.Alert.AlertType.ERROR, e.getMessage()).showAndWait();
        }
    }

    public static void main(String[] args) {
        launch(args);
    }
}